package com.Mybatis.builder;

import com.Mybatis.session.Configuration;
import com.Mybatis.type.TypeAliasRegistry;
import com.Mybatis.type.TypeHandlerRegistry;

/**
 * 就是一个基本的构建者，要用抽象修饰
 * 里面有configuration还有别名和类型注册机，子类就是从这里获取configuration
 */
public abstract class BaseBuilder {

    protected final Configuration configuration;
    protected final TypeAliasRegistry typeAliasRegistry;
    protected final TypeHandlerRegistry typeHandlerRegistry;

    public BaseBuilder(Configuration configuration) {
        this.configuration = configuration;
        this.typeAliasRegistry = this.configuration.getTypeAliasRegistry();
        this.typeHandlerRegistry = this.configuration.getTypeHandlerRegistry();
    }

    public Configuration getConfiguration() {
        return configuration;
    }

    protected Class<?> resolveAlias(String alias) {
        return typeAliasRegistry.resolveAlias(alias);
    }
}
